﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ExpertMIS.Entities;
using ExpertMIS.Brokers;
using ExpertMIS.Admin.UserControl;

namespace ExpertMIS.Admin
{
    public partial class AdminMaster : System.Web.UI.MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            RefreshModules();
        }

        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            // 记录上一次请求路径
            if (Request.UrlReferrer != null)
            {
                Session["UrlReferrer"] = Request.UrlReferrer.ToString();
            }
        }

        private void RefreshModules()
        {
            ADMMODULEBroker broker = new ADMMODULEBroker();
            dlModules.DataSource = broker.GetAllEnabledModule();
            dlModules.DataBind();
        }

        protected void dlModules_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        protected void dlModules_ItemDataBound(object sender, DataListItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
            {
                ADMMODULEEntity entity = e.Item.DataItem as ADMMODULEEntity;
                if (null != entity)
                {
                    Label lblTitle = e.Item.FindControl("lblTitle") as Label;
                    lblTitle.Text = entity.ModuleName;

                    // wdong@2009-09-12,添加导航图标
                    //Image img = e.Item.FindControl("imgNavHeader") as Image;
                    //img.ImageUrl = ResolveUrl("~/imgs/") + entity.ICON;

                    AdminFeatureMenu featureMenu = e.Item.FindControl("AdminFeatureMenu1") as AdminFeatureMenu;
                    featureMenu.SetModuleOID(entity.OID);
                }
            }
        }
    }
}
